#ifndef	__AD5274_5271_h__
#define	__AD5274_5271_h__

#include "stdint.h"
#include <stdbool.h>
#include <integer.h>
#include <IOConfig.h>

#define DEVICE_ADDRESS_VDDIO	0x58			
#define DEVICE_ADDRESS_VDD	    0x5E	
#define DEVICE_ADDRESS_DVDD  0x5C
//#define DEVICE_ADDRESS_M5	0x5C			

#define COMMAND_NOP_INDEX			0x00
#define COMMAND_WRITE_RDAC_INDEX	0x01
#define COMMAND_READ_RDAC_INDEX		0x02
#define COMMAND_STORE_RDAC_SETTNG_INDEX		0x03
#define COMMAND_REFRESH_RDAC_INDEX		0x04
#define COMMAND_READ_OTP_CONTENT_INDEX		0x05
#define COMMAND_READ_OTP_INDEX		0x06
#define COMMAND_WRITE_CONTROL_INDEX		0x07
#define COMMAND_READ_CONTROL_INDEX		0x08
#define COMMAND_SHUTDOWN_INDEX		0x09


#define AD5274_5271PIN_SCL  GPIO_PIN_4
#define AD5274_5271PIN_SDA  GPIO_PIN_6						//­×
#define GPIO_SDA                                   GPIOA
#define GPIO_SCL                                   GPIOA

//------------------------------------------------------------
#define AD5274_5271_TPSCL_L HAL_GPIO_WritePin(GPIO_SCL, AD5274_5271PIN_SCL,GPIO_PIN_RESET)  //SCL
#define AD5274_5271_TPSCL_H HAL_GPIO_WritePin(GPIO_SCL, AD5274_5271PIN_SCL,GPIO_PIN_SET)
#define AD5274_5271_TPSDA_L HAL_GPIO_WritePin(GPIO_SDA, AD5274_5271PIN_SDA,GPIO_PIN_RESET)  //SDA
#define AD5274_5271_TPSDA_H HAL_GPIO_WritePin(GPIO_SDA, AD5274_5271PIN_SDA,GPIO_PIN_SET)


void AD5274_5271_GPIO_Config(void);
void AD5274_5271_I2CSDASetInput(void);
void AD5274_5271_I2CSDASetOutput(void);
void AD5274_5271_I2CStart(void);
void AD5274_5271_I2CStop(void);
bool AD5274_5271_I2CSendByte(BYTE ucData);
BYTE AD5274_5271_I2CReciveByte(bool bAck);
bool AD5274_5271_I2CSend(BYTE ucDeviceAddr, BYTE ucIndex, u16 RDACValue);
bool AD5274_5271_I2CReceive(BYTE ucDeviceAddr, BYTE ucIndex, BYTE* pucData, unsigned int unDataLength);

unsigned int AD5274_5271_BUS_VOLTAGE(void);
void VDD_AD5274_5271_Init(u16 uvol);  
void VDDIO_AD5274_5271_Init(u16 uvol);
void DVDD_AD5274_5271_Init(u16 uvol);
void DelayMs(u16 x);
//-----------------------------------------------------------------------
#endif
